package com.realdolmen.whiteyellowcross.service;

import com.realdolmen.whiteyellowcross.datastore.WaitWorkShiftDataStore;
import com.realdolmen.whiteyellowcross.datastore.WaitWorkShiftDayPlanDataStore;
import com.realdolmen.whiteyellowcross.model.WaitWorkShift;

import java.util.Date;
import java.util.List;

/**
 * Created by ext487 on 30/04/2014.
 */
public class WaitWorkShiftPersistenceBasedService implements WaitWorkShiftService {

    private WaitWorkShiftDataStore waitWorkShiftDataStore = null;

    private static WaitWorkShiftService waitWorkShiftService;

    private WaitWorkShiftPersistenceBasedService(
            WaitWorkShiftDataStore waitWorkShiftDataStore) {
        this.waitWorkShiftDataStore = waitWorkShiftDataStore;
    }

    public static WaitWorkShiftService getInstance(
            WaitWorkShiftDataStore waitWorkShiftDataStore) {
        if (waitWorkShiftService == null) {
            synchronized (WaitWorkShiftPersistenceBasedService.class) {

                if (waitWorkShiftService == null) {
                    waitWorkShiftService = new WaitWorkShiftPersistenceBasedService(
                            waitWorkShiftDataStore);

                }
            }
        }
        return waitWorkShiftService;
    }

    @Override
    public void addWorkShift(String name, Date from, Date to, Integer hours) {
        waitWorkShiftDataStore.addWaitWorkShift(name, from, to, hours);
    }


    @Override
    public List<WaitWorkShift> getWorkShiftList() {
        return null;
    }

    @Override
    public WaitWorkShift getWorkShift(String name) {
        return waitWorkShiftDataStore.getWaitWorkShift(name);
    }

    @Override
    public void deleteWorkShift(String name) {

    }

    @Override
    public int getTotalWorkShifts() {
        return 0;
    }
}
